﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Frost {
    public class FolderTestRepository : ITestRepository {
        public string Folder { get; set; }
        public IEnumerable<string> ValidFileExtensions { get; set; }

        public FolderTestRepository(string path) {
            Folder = path;
            ValidFileExtensions = new List<string> { 
                ".html",
                ".htm"
            }; 
        }

        public IEnumerable<ITest> GetTests() {
            var files = Directory.GetFiles(Folder);
            var tests = files.Where(x => ValidFileExtensions.Contains(Path.GetExtension(x).ToLower()));
            return tests.Select(x =>
               TestFactory.ConstructTestFromFile(x)
            );

        }
        
    }
}
